package com.fz.us.admin.dict.entity;

import com.fz.us.admin.base.entity.parent.NameEntity;

import javax.persistence.*;

/**
 * 实体类 - 字典 item
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-07-14 。
 * ============================================================================
 */
@Entity
@Table(name="sys_dictitem")
public class DictItem extends NameEntity {

    private static final long serialVersionUID = 6275608960874167187L;

    public DictItem() {
    }

    public DictItem(Dict dict, String name, String value, String description, int ifKey, int ifSelectable, int sortNo, DictItem parent) {
        this.dict = dict;
        this.ifSystem = 1;
        this.name = name;
        this.value = value;
        this.description = description;
        this.ifKey = ifKey;
        this.ifSelectable = ifSelectable;
        this.sortNo = sortNo;
        this.parent = parent;
    }

    public DictItem(Dict dict, String keyId, String name, String value, String description, int sortNo, DictItem parent) {
        this.dict = dict;
        this.keyId = keyId;
        this.ifSystem = 0;
        this.name = name;
        this.value = value;
        this.description = description;
        this.ifKey = 0;
        this.ifSelectable = 0;
        this.sortNo = sortNo;
        this.parent = parent;
    }

    /**
     * 关联Id
     */
    private String keyId;
    /**
     * 是否系统设置 1/0
     */
    private int ifSystem;
    /**
     * 字典
     */
    private Dict dict;
    /**
     * 关键字
     */
    private String value;
    /**
     * 描述
     */
    private String description;
    /**
     * 是否关键字典（不允许禁用）1/0
     */
    private int ifKey;
    /**
     * 不可选 1/0 默认0可选(前提 ifKey = 1)
     */
    private int ifSelectable;
    /**
     * 排序号，如果是系统定制用4位数 1000-2000-3000-4000 自定义采用1001 1002 1003 1004 2001 2002 2003 2004
     */
    private int sortNo;
    /**
     * 父节点
     */
    private DictItem parent;

    public String getKeyId() {
        return keyId;
    }

    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    @Column(updatable = false)
    public int getIfSystem() {
        return ifSystem;
    }

    public void setIfSystem(int ifSystem) {
        this.ifSystem = ifSystem;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Dict getDict() {
        return dict;
    }

    public void setDict(Dict dict) {
        this.dict = dict;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Column(length = 5000)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getIfKey() {
        return ifKey;
    }

    public void setIfKey(int ifKey) {
        this.ifKey = ifKey;
    }

    public int getIfSelectable() {
        return ifSelectable;
    }

    public void setIfSelectable(int ifSelectable) {
        this.ifSelectable = ifSelectable;
    }

    public int getSortNo() {
        return sortNo;
    }

    public void setSortNo(int sortNo) {
        this.sortNo = sortNo;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public DictItem getParent() {
        return parent;
    }

    public void setParent(DictItem parent) {
        this.parent = parent;
    }

}
